#include <iostream>
#include <cstring>
#include <unistd.h>
#include "comm.hpp"

using namespace std;

int main()
{
    //打开管道文件
    int fd = open(FIFO_FILE,O_WRONLY);
    if(fd == -1)
    {
        cerr << "Error opening FIFO: " << strerror(errno) << endl;
        return OPENCHANNELERROR;
    }
    while(true)
    {
        char buffer[SIZE];
        cout << "Enter message: ";
        cin.getline(buffer, SIZE);
        ssize_t bytesWritten = write(fd, buffer, strlen(buffer));
        if (bytesWritten == -1)
        {
            cerr << "Error writing to FIFO: " << strerror(errno) << endl;
            break;
        }
    }
    close(fd);
    return 0;   
}